package wsem.utils;

import java.util.Properties;

import org.apache.log4j.Logger;


public class ConfigUtils {

	private static Properties PROPERTIES = null;

	private static final String CONFIG_FILE_NAME = "/wsem/resources/config.properties";

	public static String PATH_XML_DOCS;

	public static String PRECISION;

	public static String PATH_STOP_LISTE;

	public static String PATH_QUERIES;

	public static String PATH_QRELS;

	public static String URL_BD;

	public static String USER_BD;

	public static String PWD_BD;

	static {
		try {
			PROPERTIES = new Properties();

			PROPERTIES.load(ClassLoader.class
					.getResourceAsStream(CONFIG_FILE_NAME));

			PATH_XML_DOCS = getPropertyValue("indexation.pathDocs");
			URL_BD = getPropertyValue("db.url");
			USER_BD = getPropertyValue("db.user");
			PWD_BD = getPropertyValue("db.password");
			PATH_QUERIES = getPropertyValue("queries.path");
			PATH_QRELS = getPropertyValue("qrel.path");
			PRECISION = getPropertyValue("precision");

		} catch (Exception e) {
			System.out.println("Configuration non valide");
		}
	}


	public static String getPropertyValue(String key) {
		if (PROPERTIES == null) {
			return "";
		}

		return PROPERTIES.getProperty(key);
	}
}
